package org.soulraven.games.memory.engine.controller;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.util.HashMap;
import java.util.Map;

public abstract class Controller extends WindowAdapter implements ActionListener {

	private Map<String, ActionListener> resolvers = new HashMap<String, ActionListener>();

	protected abstract void onExit();

	protected Map<String, ActionListener> getResolvers() {
		return resolvers;
	}

	@Override
	public void actionPerformed(final ActionEvent e) {
		Component source = (Component) e.getSource();
		resolvers.get(source.getName()).actionPerformed(e);
	}
}
